require('./Sliderselectinfo.styl');
import Icon from 'salt-icon'
import { Boxs, Group, TextField, TextareaField } from 'saltui';
const { HBox, Box, VBox } = Boxs;
class Sliderselectinfo extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            text: ""
        };
        this.handleClickListItem = this.handleClickListItem.bind(this);
    }
    //列表项点击
    handleClickListItem() {
        this.props.handleClickListItem && this.props.handleClickListItem();
    }
    render() {
        let t = this;
        return (
            <div className="sliderselectinfo">
                <Group.List className="t-LH44" >
                    <HBox vAlign="center" className="t-PL10 t-PR10 sliderselectinfo-head" onClick={this.handleClickListItem}>
                        <Box flex={1} className="sliderselectinfo-title">{this.props.title}</Box>
                        <Box flex={1} className="t-FAR">
                            <Icon name={this.props.IconName} fill="#0160B8" width="20" height="20" />
                        </Box>
                    </HBox>
                </Group.List>
                {this.props.rows ?
                    <TextareaField
                        layout="v"
                        minRows={isNaN(this.props.rows) ? this.props.rows : 1}
                        maxRows={this.props.rows + 2}
                        value={t.state.text}
                        readOnly={true}
                    />
                    :
                    <TextField
                        label=""
                        value={t.state.text}
                        readOnly={true}
                    />
                }
            </div>
        );
    }

    componentWillMount() {
    }

    componentDidMount() {
    }

    componentWillReceiveProps(nextProps) {
        if (nextProps.text && nextProps.text != this.state.text) {
            this.setState({ text: nextProps.text })
        }
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {
    }
}

module.exports = Sliderselectinfo;
